package com.breeze.blockchain.task;

import com.breeze.blockchain.socket.handler.service.OnlineCountService;
import com.breeze.components.task.lock.LockScheduled;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 在线人数推送任务
 *
 * @author breeze
 */
@Component
@Slf4j
public class OnlineCountJob {

  @Resource private OnlineCountService onlineCountService;

  /** 每5s推送在线人数 */
  @LockScheduled(value = DistributedLockKey.ONLINE_COUNT_LOCK, fixedRate = 5000)
  public void onlineTicker() {
    onlineCountService.pushOnlineCount();
  }
}
